<?php

class BackendArticleRecommendationLogFormFilter extends ArticleRecommendationLogFormFilter
{
  public function configure()
  {
    $this->widgetSchema['article']    = new sfWidgetFormInputText();
    $this->validatorSchema['article'] = new sfValidatorPass();

    $table = $this->getModelName() . 'Table';
    $types = $table::$status;
    $types[''] = '';
    ksort($types);
    $this->widgetSchema['status']     = new sfWidgetFormChoice(array(
      'choices' => $types
    )); 
    $this->validatorSchema['status']  = new sfValidatorPass();

    $this->widgetSchema['proposer_id'] = new sfWidgetFormDoctrineChoice(array(
      'model'        => $this->getRelatedModelName('proposer'),
      'table_method' => 'getEditorsQuery',
      'add_empty'    => true
    ));
  }

  public function addArticleColumnQuery(Doctrine_Query $query, $field, $values)
  {
    $query->addWhere('a.title like ?', "%{$values}%");
  }

  public function addStatusColumnQuery(Doctrine_Query $query, $field, $values)
  {
    $rootAlias = $query->getRootAlias();

    $query->addWhere("$rootAlias.$field = ?", $values);
  }
}
